import cv2
import numpy as np

# 读取图像
image = cv2.imread('Bright1.jpg')  # 替换为你的图片路径

# 检查图像是否成功读取
if image is None:
    print("无法读取图像")
    exit()

# 转换为灰度图像
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# 创建 CLAHE 对象
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))

# 应用 CLAHE
clahe_image = clahe.apply(gray_image)

# 显示结果
cv2.imshow('Original Image', gray_image)
cv2.imshow('CLAHE Image', clahe_image)
cv2.waitKey(0)
cv2.destroyAllWindows()